package com.apestech.formwork.xml.core;

import com.apestech.framework.json.JSONObject;

/**
 * Xml结点有关的KEY值关键字
 *
 * @author hup
 * @create 2018-03-23-12:01
 */
public class NodeVar {

    public static String DEFAULT_XML_DIR="D:\\mywork\\yyesb\\server\\config\\query\\";

    public static String XML_OUT_KEY="xmlOutputKey";   //xml文件输出存放相对目录
    public static String DATABASE="database";  //数据库别名，不配默认取当前唯一数据源
    public static String XML_KEY="xmlKey";   //XML文件所在位置的相对路径，不包括默认主路径
    public static String MEMO="memo";    //备注关键字
    public static String SELECT="select";  //查询SQL
    public static String INSERT="insert";  //插入SQL
    public static String UPDATE="update";  //更新SQL
    public static String DELETE="delete";  //删除SQL
    public static String EXPRESS="express";    //公式
    public static String NESTED="nested";    //子关联,指令式XML里存在循环处理逻辑

    public static String SPLIT="split";    //分割符
    public static String FIELD="field";    //字段结点  mapping专用
    public static String STEP="step";    //步骤结点

    public static String MAPPING="config";   //数据MAPPING的结点名
    public static String ROW="row";

    public static String CLASS="class";    //JAVA类
    public static String METHOD="method";    //JAVA方法名
    public static String HTTP="http";      //http访问地址

    public static String EXECUTION="execution";
    public static String EXECUTE="execute";
    public static String DEFINE="define";
    public static String TYPE="type";   //类型
    public static String WHILE="while";   //循环
    public static String SQLWHERE="sqlWhere";   //SQL的WHERE条件
    public static String PRIORITY="priority";   //优先级
    public static String ERROR="error";   //错误提示信息

    public static String CONDITION="condition";   //条件类型
    public static String PRICING_PROCESS="pricingProcess";   //定价过程
    public static String RULE_ENGINE="ruleEngine";   //规则引擎
    public static String QUERY_ID="queryId";   //查询ID
    public static String CONDITION_ID="conditionId";   //条件类型ID
    public static String PRICING_PROCESS_ID="pricingProcessId";   //定价过程ID
    public static String RULE_ENGINE_ID="ruleEngineId";   //规则引擎ID

    public static String PRECONDITIONS="preconditions";    //前置条件
    public static String INPUT="input";    //输入参数
    public static String OUTPUT="output";    //输出参数
    public static String RESULT_FORMAT="resultFormat"; //返回数据格式
    public static String FINAL_FORMAT="finalFormat";   //最终数据返回格式

    public static String FIELD_NESTED_ID="id";   //子表对应ID主键名
    public static String TABLE_NAME="tablename";    //表名
    public static String FIELD_ID="attrname";    //字段ID
    public static String TARGET="target";    //目标
    public static String FIELD_TYPE="fieldtype";    //字段类型
    public static String FIELD_NAME="name";    //中文名称
    public static String ALLOW_NULL="allownull";    //允许为空
    public static String DEFAULT_VALUE="defaultValue";    //默认值
    public static String FIELD_CHECK="check";    //数据检查
    public static String VALUE="value";    //值
    public static String MATH="math";    //数学公式

    public static String DEFAULT_TIMESTAMP_FIELD="LAST_UPDATED_STAMP";
    public static String TIMESTAMP_FIELD="timeStampField";

    public static JSONObject NODE_MAP;
    public static JSONObject PATH_MAP;

    public static void setDefaultXmlDir(String defaultXmlDir) {
        DEFAULT_XML_DIR = defaultXmlDir;
    }

    public static void setXmlOutKey(String xmlOutKey) {
        XML_OUT_KEY = xmlOutKey;
    }

    public static void setDATABASE(String DATABASE) {
        NodeVar.DATABASE = DATABASE;
    }

    public static void setXmlKey(String xmlKey) {
        XML_KEY = xmlKey;
    }

    public static void setMEMO(String MEMO) {
        NodeVar.MEMO = MEMO;
    }

    public static void setSELECT(String SELECT) {
        NodeVar.SELECT = SELECT;
    }

    public static void setINSERT(String INSERT) {
        NodeVar.INSERT = INSERT;
    }

    public static void setUPDATE(String UPDATE) {
        NodeVar.UPDATE = UPDATE;
    }

    public static void setDELETE(String DELETE) {
        NodeVar.DELETE = DELETE;
    }

    public static void setEXPRESS(String EXPRESS) {
        NodeVar.EXPRESS = EXPRESS;
    }

    public static void setNESTED(String NESTED) {
        NodeVar.NESTED = NESTED;
    }

    public static void setSPLIT(String SPLIT) {
        NodeVar.SPLIT = SPLIT;
    }

    public static void setFIELD(String FIELD) {
        NodeVar.FIELD = FIELD;
    }

    public static void setSTEP(String STEP) {
        NodeVar.STEP = STEP;
    }

    public static void setMAPPING(String MAPPING) {
        NodeVar.MAPPING = MAPPING;
    }

    public static void setCLASS(String CLASS) {
        NodeVar.CLASS = CLASS;
    }

    public static void setMETHOD(String METHOD) {
        NodeVar.METHOD = METHOD;
    }

    public static void setHTTP(String HTTP) {
        NodeVar.HTTP = HTTP;
    }

    public static void setCONDITION(String CONDITION) {
        NodeVar.CONDITION = CONDITION;
    }

    public static void setPricingProcess(String pricingProcess) {
        PRICING_PROCESS = pricingProcess;
    }

    public static void setRuleEngine(String ruleEngine) {
        RULE_ENGINE = ruleEngine;
    }

    public static void setQueryId(String queryId) {
        QUERY_ID = queryId;
    }

    public static void setConditionId(String conditionId) {
        CONDITION_ID = conditionId;
    }

    public static void setPricingProcessId(String pricingProcessId) {
        PRICING_PROCESS_ID = pricingProcessId;
    }

    public static void setRuleEngineId(String ruleEngineId) {
        RULE_ENGINE_ID = ruleEngineId;
    }

    public static void setPRECONDITIONS(String PRECONDITIONS) {
        NodeVar.PRECONDITIONS = PRECONDITIONS;
    }

    public static void setINPUT(String INPUT) {
        NodeVar.INPUT = INPUT;
    }

    public static void setOUTPUT(String OUTPUT) {
        NodeVar.OUTPUT = OUTPUT;
    }

    public static void setFieldNestedId(String fieldNestedId) {
        FIELD_NESTED_ID = fieldNestedId;
    }

    public static void setFieldId(String fieldId) {
        FIELD_ID = fieldId;
    }

    public static void setTARGET(String TARGET) {
        NodeVar.TARGET = TARGET;
    }

    public static void setFieldType(String fieldType) {
        FIELD_TYPE = fieldType;
    }

    public static void setFieldName(String fieldName) {
        FIELD_NAME = fieldName;
    }

    public static void setAllowNull(String allowNull) {
        ALLOW_NULL = allowNull;
    }

    public static void setDefaultValue(String defaultValue) {
        DEFAULT_VALUE = defaultValue;
    }

    public static void setFieldCheck(String fieldCheck) {
        FIELD_CHECK = fieldCheck;
    }

    public static void setVALUE(String VALUE) {
        NodeVar.VALUE = VALUE;
    }

    public static void setMATH(String MATH) {
        NodeVar.MATH = MATH;
    }

    public static void setDEFINE(String DEFINE) {
        NodeVar.DEFINE = DEFINE;
    }

    public static void setTYPE(String TYPE) {
        NodeVar.TYPE = TYPE;
    }

    public static void setWHILE(String WHILE) {
        NodeVar.WHILE = WHILE;
    }

    public static void setPRIORITY(String PRIORITY) {
        NodeVar.PRIORITY = PRIORITY;
    }

    public static void setResultFormat(String resultFormat) {
        RESULT_FORMAT = resultFormat;
    }

    public static void setFinalFormat(String finalFormat) {
        FINAL_FORMAT = finalFormat;
    }

    public static void setTableName(String tableName) {
        TABLE_NAME = tableName;
    }

    public static void setEXECUTION(String EXECUTION) {
        NodeVar.EXECUTION = EXECUTION;
    }

    public static void setSQLWHERE(String SQLWHERE) {
        NodeVar.SQLWHERE = SQLWHERE;
    }

    public static void setERROR(String ERROR) {
        NodeVar.ERROR = ERROR;
    }

    public static void setEXECUTE(String EXECUTE) {
        NodeVar.EXECUTE = EXECUTE;
    }

    public static String getDefaultXmlDir() {
        return DEFAULT_XML_DIR;
    }

    public static String getXmlOutKey() {
        return XML_OUT_KEY;
    }

    public static String getDATABASE() {
        return DATABASE;
    }

    public static String getXmlKey() {
        return XML_KEY;
    }

    public static String getMEMO() {
        return MEMO;
    }

    public static String getSPLIT() {
        return SPLIT;
    }

    public static String getMAPPING() {
        return MAPPING;
    }

    public static String getROW() {
        return ROW;
    }

    public static void setROW(String ROW) {
        NodeVar.ROW = ROW;
    }

    public static String getDefaultTimestampField() {
        return DEFAULT_TIMESTAMP_FIELD;
    }

    public static void setDefaultTimestampField(String defaultTimestampField) {
        DEFAULT_TIMESTAMP_FIELD = defaultTimestampField;
    }

    public static String getTimestampField() {
        return TIMESTAMP_FIELD;
    }

    public static void setTimestampField(String timestampField) {
        TIMESTAMP_FIELD = timestampField;
    }

    private static void nodeMapIni(){
        NODE_MAP=new JSONObject();
        NODE_MAP.put("select", "sql");
        NODE_MAP.put("update", "sql");
        NODE_MAP.put("insert", "sql");
        NODE_MAP.put("delete", "sql");
        NODE_MAP.put("conditionDef", "condition");
        NODE_MAP.put("conditionStrategyDef", "condition");
        NODE_MAP.put("report", "report");
    }

    private static void pathMapIni(){
        PATH_MAP=new JSONObject();
        PATH_MAP.put("SQL", "1");
        PATH_MAP.put("condition", "1");
        PATH_MAP.put("report", "1");
    }

    public static JSONObject getNodeMap() {
        if(NODE_MAP==null) nodeMapIni();
        return NODE_MAP;
    }

    public static JSONObject getPathMap() {
        if(PATH_MAP==null) pathMapIni();
        return PATH_MAP;
    }
}
